<?php
/*
 * @Author:  哲学家乔布斯 <wuyangii@qq.com>
 * @Date: 2023-03-19 12:50:09
 * @LastEditors: 哲学家乔布斯 <wuyangii@qq.com>
 * @LastEditTime: 2023-03-19 19:14:32
 * @Descripttion: 代理商资金日志
 */

namespace app\admin\controller\rider;
use think\Db;
class Log extends \app\admin\controller\Common
{
    public function index(){
        return view();
    }

    public function list(){
        $limit = request()->param('limit') ?? 15;
        $page = request()->param('page');
        $page = $page ? ($page - 1) * $limit : 0;
        $search = request()->param();
        $query = (new \app\common\model\RiderLog())
                ->alias('rider_log')
                ->join("{$this->tdb}agent agent",'agent.id = rider_log.agent_id')
                ->field([
                    'rider_log.id',
                    'rider_log.money',
                    'rider_log.order_type',
                    'rider_log.type',
                    'rider_log.addtime',
                    'rider_log.agent_id'
                ]);
        isset($search['agent_name']) && $search['agent_name'] != "" ? $query->where("agent.name like '%{$search['agent_name']}%'") : '';
        isset($search['order_type']) && $search['order_type'] != 0 ? $query->where("rider_log.order_type",$search['order_type']) : '';
        $query->order("rider_log.id desc");
        $query->append(['addtime_text','order_type_text','type_text','agent_name_text']);
        $list = $query->limit($page, $limit)->select();
        $count = $query->count();
        return self::successResult('',$list,$count);
    }

    public function info(){
        $id = request()->param('id');
        $id = intval(request()->param('id'));
        $info = (new \app\common\model\AgentLog())->where(['id' => $id])->find();
        $this->assign('info',$info);
        return view();
    }

  

 
}
